package com.lotto.manager.common.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.lotto.manager.admin.system.SystemData;
import com.lotto.manager.common.constant.SystemConstant;

public class LottoUtil {

	// 生肖
	private static Map<String, String> zodiacNumber = new HashMap<String, String>();
	// 五行
	private static Map<String, String> wuXingNumber = new HashMap<String, String>();
	// 波色
	private static Map<String, String> colorNumber = new HashMap<String, String>();
	// 合数单双
	private static Map<String, String> sunSingleDoubleNumber = new HashMap<String, String>();
	// 单双
	private static Map<String, String> singleDoubleNumber = new HashMap<String, String>();
	// 大小
	private static Map<String, String> bigSmallNumber = new HashMap<String, String>();

	/**
	 * 方法名称: main 描述: 参数：@param args
	 * 
	 * @throws
	 */
	public static void main(String[] args) {
		initSingleDouble();
	}

	public static void initNumber() {
		initZodiacs();
		initWuXing();
		initColor();
		initSunSingleDouble();
		initSingleDouble();
		initBigSmall();
	}


	public static void initZodiacs() {
		String thisYear = SystemData.getSysConfig().getZodiac();
		int numberIndex = 0;
		for (int i = 0; i < SystemConstant.ZODIACS.length; i++) {
			if (thisYear.equals(SystemConstant.ZODIACS[i])) {
				numberIndex = i;
				break;
			}
		}
		addMapData(zodiacNumber, SystemConstant.ZODIACS, numberIndex);
	}

	public static void initWuXing() {
		addMapData(wuXingNumber, SystemConstant.WUXING, 0);
	}

	public static void initColor() {
		int basis = 0;
		int index = 0;
		for (int i = 0; i < SystemConstant.BASISNUMBER.length; i++) {
			colorNumber.put(SystemConstant.BASISNUMBER[i],
					SystemConstant.COLOR[index]);
			/*System.out.println(SystemConstant.BASISNUMBER[i] + "|"
					+ SystemConstant.WAVECOLOR[index]);*/
			basis++;
			if (basis >= 2 || 0 == (i + 1) % 10) {
				if (basis >= 2 && 0 == (i + 1) % 10) {
					basis = 1;
				} else {
					basis = 0;
				}
				index++;
			}
			if (index >= (SystemConstant.COLOR.length)) {
				index = 0;
			}
		}
	}
	
	
	public static void initSunSingleDouble() {
		for (int i = 0; i < SystemConstant.BASISNUMBER.length; i++) {
			int bits = Integer.valueOf(SystemConstant.BASISNUMBER[i].substring(0, 1));
			int ten = Integer.valueOf(SystemConstant.BASISNUMBER[i].substring(1, 2));
			if((bits+ten)%2 == 0){
				sunSingleDoubleNumber.put(SystemConstant.BASISNUMBER[i], "合双");
				/*System.out.println(SystemConstant.BASISNUMBER[i] + "|"
						+ "合双");*/
			}else{
				sunSingleDoubleNumber.put(SystemConstant.BASISNUMBER[i], "合单");
				/*System.out.println(SystemConstant.BASISNUMBER[i] + "|"
						+ "合单");*/
			}
		}
	}
	
	public static void initSingleDouble() {
		for (int i = 0; i < SystemConstant.BASISNUMBER.length; i++) {
			if("49".equals(SystemConstant.BASISNUMBER[i])){
				singleDoubleNumber.put(SystemConstant.BASISNUMBER[i], "和");
				/*System.out.println(SystemConstant.BASISNUMBER[i] + "|"
						+ "和");*/
			}else if(Integer.valueOf(SystemConstant.BASISNUMBER[i])%2 == 0){
				singleDoubleNumber.put(SystemConstant.BASISNUMBER[i], "双");
				/*System.out.println(SystemConstant.BASISNUMBER[i] + "|"
						+ "双");*/
			}else{
				singleDoubleNumber.put(SystemConstant.BASISNUMBER[i], "单");
				/*System.out.println(SystemConstant.BASISNUMBER[i] + "|"
						+ "单");*/
			}
		}
	}
	
	public static void initBigSmall(){
		for (int i = 0; i < SystemConstant.BASISNUMBER.length; i++) {
			if("49".equals(SystemConstant.BASISNUMBER[i])){
				bigSmallNumber.put(SystemConstant.BASISNUMBER[i], "和");
			}else if(Integer.valueOf(SystemConstant.BASISNUMBER[i])>=25){
				bigSmallNumber.put(SystemConstant.BASISNUMBER[i], "大");
				/*System.out.println(SystemConstant.BASISNUMBER[i] + "|"
						+ "双");*/
			}else{
				bigSmallNumber.put(SystemConstant.BASISNUMBER[i], "小");
				/*System.out.println(SystemConstant.BASISNUMBER[i] + "|"
						+ "单");*/
			}
		}
	}
	
	
	
	
	public static String yearZodiacByNumber(String number) {
		return zodiacNumber.get(number);
	}

	public static void addMapData(Map<String, String> map, String[] basisData,
			int index) {
		for (int i = 0; i < SystemConstant.BASISNUMBER.length; i++) {
			map.put(SystemConstant.BASISNUMBER[i], basisData[index]);
			index++;
			if (index >= (basisData.length)) {
				index = 0;
			}
		}
	}

}
